package com.atguigu.srb.core.controller.api;


import com.atguigu.srb.common.result.R;
import com.atguigu.srb.core.entity.Lend;
import com.atguigu.srb.core.entity.vo.LendSearchVo;
import com.atguigu.srb.core.service.LendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 标的准备表 前端控制器
 * </p>
 *
 * @author Atguigu
 * @since 2023-06-30
 */
@Api(tags = "标的带条件查询模块")
@RestController
@RequestMapping("/api/core/lend")
public class ApiLendController {
    @Resource
    LendService lendService;
    @GetMapping("/conditions/lists")
    @ApiOperation("根据条件查询标的列表")
    public R getLendLists(LendSearchVo lendSearchVo){
        //带条件查询的模块
        List<Lend> lendLists = lendService.getLendLists(lendSearchVo);
        return R.ok().data("items",lendLists);
    }
    @ApiOperation("根据标的id查询标的详情")
    @GetMapping("/detail/{lendId}")
    public R getLendDetail(@PathVariable("lendId")Long lendId){
        Map<String, Object> map = lendService.getDetailById(lendId);
        return R.ok().data(map);
    }
}

